const express = require('express');
const app = express();
app.get('/', (req, res) => res.send('Hello, Express!'));

const users = {
    admin: '12345678'
}
let count = 0
app.get('/login', (req, res) => {
    let data = req.query;
    let username = data.username;
    if (username === undefined) {
        res.send('用户名不能为空！')
        return
    }
    if (users[username] === undefined) {
        res.send('用户名不存在！')
        return
    }
    if (users[username] !== data.password) {
        res.send('密码错误！')
        return
    } else {
        count++
        res.send('登录成功！')
        console.log(`第${count}次登录`)
        return
    }
});

app.listen(3000, () => console.log('服务器启动： http://localhost:3000'));